﻿<%@ Page Language="c#" CodeBehind="Index.aspx.cs" AutoEventWireup="false" Inherits="UDS.SubModule.UnitiveDocument.Mail.MailListPage" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
  <title>Mail List Page</title>
  <script language="javascript" type="text/javascript">
    //<!--
    function selectAll(checked) {
      var dg = document.getElementById("<%= dgMailList.ClientID %>");
      var inputs = dg.getElementsByTagName("input");
      for (var i = 0; i < inputs.length; i++) {
        var input = inputs[i];
        if (input.type === "checkbox") {
          input.checked = checked;
        }
      }
    }
    //-->
  </script>
  <uds:Style runat="server" Href="~/css/BasicLayout.css" />
  <style type="text/css">
    .innerTable
    {
      border: 0px;
    }
    .innerTable td
    {
      border: 0px;
      padding: 0px;
    }
  </style>
</head>
<body>
  <form method="post" runat="server">
  <uds:PageTitle runat="server" Title="我的邮件" HintImage="~/images/icon/284.GIF">
    <asp:Label ID="lblMsg" runat="server" />
    <span>&nbsp;&nbsp;</span>
    <asp:Button ID="btnClear" runat="server" Visible="False" Text="清 空" CssClass="redbuttoncss optionbutton" OnClientClick="javascript:return confirm('您确认要清空吗?');" />
    <asp:Button ID="btnDelete" runat="server" Text="删 除" CssClass="redbuttoncss optionbutton" OnClientClick="javascript:return confirm('您确认要删除吗?');" />
    <input onclick="selectAll(true)" type="button" value="全 选" class="redbuttoncss optionbutton" />
    <input onclick="selectAll(false)" type="button" value="取 消" class="redbuttoncss optionbutton" />
    <asp:DropDownList ID="listFolderType" runat="server" AutoPostBack="True" OnSelectedIndexChanged="FolderListChange" />
  </uds:PageTitle>
  <div>
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
      <tr>
        <td class="<%= (FolderType == MailFolderType.Index) ? "selectedTab" : "unselectedTab"%>">
          <a href="Index.aspx?FolderType=<%= (int)MailFolderType.Index %>" class="Newbutton">收件箱</a>
        </td>
        <td class="<%= (FolderType == MailFolderType.Outbox) ? "selectedTab" : "unselectedTab"%>">
          <a href="Index.aspx?FolderType=<%= (int)MailFolderType.Outbox %>" class="Newbutton">发件箱</a>
        </td>
        <td class="<%= (FolderType == MailFolderType.RecyleBin) ? "selectedTab" : "unselectedTab"%>">
          <a href="Index.aspx?FolderType=<%= (int)MailFolderType.RecyleBin %>" class="Newbutton">废件箱</a>
        </td>
        <% if (ShowExternalMail)
           { %>
        <td class="<%= (FolderType == MailFolderType.ExternalMail) ? "selectedTab" : "unselectedTab"%>">
          <a href="Index.aspx?FolderType=<%= (int)MailFolderType.ExternalMail %>" class="Newbutton">外部邮件</a>
        </td>
        <%} %>
        <td class="unselectedTab">
          <a href="Compose.aspx?ClassID=0" class="Newbutton">撰写新邮件</a>
        </td>
        <td align="right">
          <span>&nbsp;</span>
          <asp:DropDownList ID="listExtMail" runat="server" Visible="false" />
          <asp:Button ID="btnBeginReceive" runat="server" CssClass="redButtonCss" Text="开始接收" Visible="false" />
          <uds:RedirectButton ID="btnExtPopSetup" runat="server" CssClass="redButtonCss" Text="外部邮箱设置" RedirectUrl="External/SetupNavi.aspx" Visible="false" />
        </td>
      </tr>
    </table>
  </div>
  <uds:UDSDataGrid ID="dgMailList" runat="server" DataKeyField="ID" CssClass="datagrid fixedtable" OnSortCommand="DataGrid_Sort" AllowSorting="True" OnPageIndexChanged="DataGrid_PageChanged">
    <Columns>
      <asp:TemplateColumn HeaderText="选择">
        <HeaderStyle HorizontalAlign="Center" Width="40px" />
        <ItemTemplate>
          <asp:CheckBox ID="grpMailID" Checked="False" runat="server" />
        </ItemTemplate>
      </asp:TemplateColumn>
      <asp:TemplateColumn HeaderText="邮件主题">
        <HeaderStyle HorizontalAlign="Left" Width="100%" />
        <ItemTemplate>
          <table border="0" cellpadding="0" cellspacing="0" class="fixedTable innerTable" style="width: 100%">
            <tr>
              <td style="width: 100%;">
                <a href="ReadMail.aspx?MailId=<%# ((MailInfo)Container.DataItem).ID %>&CurrentPageIndex=<%=CurrentPageIndex%>&FolderType=<%=(int)FolderType %>">
                  <%# HttpUtility.HtmlEncode( ((MailInfo)Container.DataItem).Subject ) %>
                </a>
              </td>
              <td style="width: 20px;">
                <asp:Image runat="server" ImageUrl="~/DataImages/attach.gif" ImageAlign="AbsMiddle" BorderWidth="0" Visible="<%# ((MailInfo)Container.DataItem).NumAttachFiles > 0 %>" />
              </td>
            </tr>
          </table>
        </ItemTemplate>
      </asp:TemplateColumn>
      <asp:BoundColumn DataField="Sender" SortExpression="Sender" HeaderText="发送者">
        <HeaderStyle Width="100px" />
      </asp:BoundColumn>
      <asp:TemplateColumn HeaderText="接收者">
        <HeaderStyle Width="100px" />
        <ItemTemplate>
          <%--<%# HttpUtility.HtmlEncode( ((MailInfo)Container.DataItem).Receiver ) %>--%>
        </ItemTemplate>
      </asp:TemplateColumn>
      <asp:TemplateColumn HeaderText="所有接收者">
        <HeaderStyle Width="100px" />
        <ItemTemplate>
          <%# HttpUtility.HtmlEncode( GetRealNameStr(((MailInfo)Container.DataItem).ReceiverList) ) %>
        </ItemTemplate>
      </asp:TemplateColumn>
      <asp:TemplateColumn HeaderText="是否已读">
        <HeaderStyle Width="80px" />
        <ItemTemplate>
          <asp:Image runat="server" ImageAlign="AbsMiddle" ImageUrl='<%# ((MailInfo)Container.DataItem).IsNew ? "~/images/MailOpen.gif" : "~/Images/MailClose.gif"%>' />
        </ItemTemplate>
      </asp:TemplateColumn>
      <asp:BoundColumn DataField="ClassName" SortExpression="ClassName" HeaderText="所属项目" Visible="false" />
      <asp:TemplateColumn SortExpression="AttachSize" HeaderText="大小(KB)">
        <HeaderStyle Width="100px" />
        <ItemTemplate>
          <%# Math.Max(1, (((MailInfo)Container.DataItem).AttachSize+1023)/1024) %>
        </ItemTemplate>
      </asp:TemplateColumn>
      <asp:TemplateColumn SortExpression="TimeSent" HeaderText="日期">
        <HeaderStyle Width="150px" />
        <ItemTemplate>
          <%# Utility.FormatDateTime( ((MailInfo)Container.DataItem).TimeSent ) %>
        </ItemTemplate>
      </asp:TemplateColumn>
    </Columns>
  </uds:UDSDataGrid>
  </form>
</body>
</html>
